package com.hello.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class UploadController {

	/**
	 * @return 上传文件解析 @Title: fileTo @Description:
	 * TODO(这里用一句话描述这个方法的作用) @param @param file 设定文件 @return void 返回类型 @throws
	 */
	@PostMapping("/uploadto")
	@ResponseBody
	public Map<String, Object> fileTo(@RequestParam("file") MultipartFile file, @RequestParam("fileid") String fileid,
			HttpServletRequest request) {
		Map<String, Object> m = new HashMap<>();
		String fileName = file.getOriginalFilename();
		String ftype = fileName.substring(fileName.lastIndexOf(".") + 1);
		m.put("fileName", fileName);
		m.put("ftype", ftype);
		m.put("attid", Math.random() * (0 + 5));
		m.put("code", 200);
		return m;
	}

}
